atlas book skeleton by Unknown
Author:Unknown
Language: eng
Format: mobi, epub
Helper utilities and other features
A utility class is one that contains miscellaneous helper methods that do not concretely fit into any other class. In essence, it is a random collection of useful things. Glitcher VR has one such class, aptly named Glitcher_Utils, that contains methods to compile shader programs, and save and load preferences between application launches.
There isn’t anything particularly special about this class, but since it is handy and generic enough to be used in any graphical project (with slight modification), I will reproduce the code here:
public class Glitcher_Utils { public static final String LOG_TAG="glitcher_log"; public static final int V_SHADE=0, F_SHADE=1, S_PROG=2; public static final String SAVE_SHARED_FILENAME="net.dystopiazero.theglitcher.sharedprefs"; public static final String SAVE_LAST_EFFECT="last_effect"; public static final String SAVE_LAST_MODE="last_mode"; public static final String SAVE_LAST_CAM_INDEX="last_cam_index"; public static void savePreference(String tag, String val, Context context) { SharedPreferences prefs=context.getSharedPreferences(SAVE_SHARED_FILENAME,Context.MODE_PRIVATE); SharedPreferences.Editor editor=prefs.edit(); editor.putString(tag, val); editor.commit(); } public static String getPreference(String tag, Context context) { SharedPreferences prefs=context.getSharedPreferences(SAVE_SHARED_FILENAME,Context.MODE_PRIVATE); String val=prefs.getString(tag, "null"); return val; } public static boolean compileShaders(String vertex_shader, String fragment_shader, int[] ids) { if (ids.length<3) { Log.e(LOG_TAG,"Glitcher_Utils,compileShaders: Buffer too small"); return false; } ids[V_SHADE]=GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER); ids[F_SHADE]=GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER); GLES20.glShaderSource(ids[V_SHADE],vertex_shader); GLES20.glShaderSource(ids[F_SHADE],fragment_shader); GLES20.glCompileShader(ids[V_SHADE]); GLES20.glCompileShader(ids[F_SHADE]); int[] info=new int[1]; GLES20.glGetShaderiv(ids[V_SHADE], GLES20.GL_COMPILE_STATUS, info,0); if (info[0]==0) { Log.e(Glitcher_Utils.LOG_TAG,"Glitcher_Utils,compileShaders: Vertex Shader Error: "+GLES20.glGetShaderInfoLog(ids[V_SHADE])); GLES20.glDeleteShader(ids[V_SHADE]); return false; } GLES20.glGetShaderiv(ids[F_SHADE], GLES20.GL_COMPILE_STATUS, info,0); if (info[0]==0) { Log.e(Glitcher_Utils.LOG_TAG,"Glitcher_Utils,compileShaders: Fragment Shader Error: "+GLES20.glGetShaderInfoLog(ids[F_SHADE])); GLES20.glDeleteShader(ids[F_SHADE]); return false; } ids[S_PROG]=GLES20.glCreateProgram(); GLES20.glAttachShader(ids[S_PROG],ids[V_SHADE]); GLES20.glAttachShader(ids[S_PROG],ids[F_SHADE]); GLES20.glLinkProgram(ids[S_PROG]); IntBuffer inf=IntBuffer.wrap(info); GLES20.glGetProgramiv(ids[S_PROG], GLES20.GL_LINK_STATUS, inf); if (info[0]==GLES20.GL_FALSE) { Log.e(Glitcher_Utils.LOG_TAG,"Glitcher_Utils,compileShaders: Shader Program Link Error: "+GLES20.glGetProgramInfoLog(ids[S_PROG])); GLES20.glDeleteProgram(ids[S_PROG]); return false; } return true; } }
The savePreference() and getPreference() methods save and retrieve a String value using Android’s SharedPreferences class, which can be used to save data between application launches. In Glitcher VR, these methods are used to save information about the active filter, active camera, and whether VR mode is enabled on program exit. On program startup, the preferences are retrieved and the previously active effect is selected, the previously active camera is opened, and VR mode is appropriately toggled.
Likewise, the static compileShaders() method compiles a vertex and fragment shader, links them to a shader program, and places their identifiers in an array that is supplied by the caller. This method is called at least once from every filter, and used in other parts of Glitcher VR that require things to be rendered to the screen, such as the notification system. As this method performs a common generic task, it can be plugged into any OpenGL program with minimal modification.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Personalized inhaled bacteriophage therapy for treatment of multidrug-resistant Pseudomonas aeruginosa in cystic fibrosis by unknow(175678)
CONSORT 2025 statement: updated guideline for reporting randomized trials by unknow(84103)
Critical evaluation of the ProfiLER-02 study design and outcomes by Vivek Subbiah & Razelle Kurzrock(83744)
Cardiac gene therapy makes a comeback by Oliver J. Müller & Susanne Hille & Anca Kliesow Remes(83547)
Whisky: Malt Whiskies of Scotland (Collins Little Books) by dominic roskrow(74438)
Unveiling the design rules for tunable emission in graphene quantum dots: A high-throughput TDDFT and machine learning perspective by Şener Özönder & Mustafa Coşkun Özdemir & Caner Ünlü(50893)
A yeast-based oral therapeutic delivers immune checkpoint inhibitors to reduce intestinal tumor burden by unknow(40260)
Covalent hitchhikers guide proteins to the nucleus by Alexander F. Russell & Madeline F. Currie & Champak Chatterjee(40216)
Meet the Authors: Christopher R. Mansfield and Emily R. Derbyshire by Christopher R. Mansfield & Emily R. Derbyshire(40096)
Alkaline-earth metals promote propane dehydrogenation with carbon dioxide through geometric effects: Altering the reaction pathway by unknow(32731)
Induced iron vacancies boosting FeOOH loaded on sustainable Fenton-like collagen fiber membrane for efficient removal of emerging contaminants by unknow(32508)
Efficient electric-field-assisted photochemical conversion of methane to n-propanol exclusively over penetrated TiO2Ti hollow fibers by Guanghui Feng(32453)
Bi2SiO5 nanosheets as piezo-photocatalyst for efficient degradation of 2,4-Dichlorophenol by Hangyu Shi & Yifu Li & Lishan Zhang & Guoguan Liu & Qian Zhang & Xuan Ru & Shan Zhong(32387)
A novel NDIPTA organic heterojunction photocatalyst with built-in electric field for efficient hydrogen production by Jiahui Yang & Baojun Ma & Yongfa Zhu(32361)
Enhanced conversion of methane to liquid-phase oxygenates via hollow ferrite nanotube@horseradish peroxidase based photoenzymatic catalysis by Jun Duan & Shiying Fan & Xinyong Li & Shaomin Liu(32333)
Ordered macroporous superstructure of defective carbon adorned with tiny cobalt sulfide for selective electrocatalytic hydrogenation of cinnamaldehyde by Xiao-Shi Yuan & Sheng-Hua Zhou & San-Mei Wang & Wenbo Wei & Xiaofang Li & Xin-Tao Wu & Qi-Long Zhu(32257)
What's Done in Darkness by Kayla Perrin(27148)
Topological analysis of non-conjugated ethylene oxide cored dendrimers decorated with tetraphenylethylene: Insights from degree-based descriptors using the polynomial approach by A Theertha Nair & D Antony Xavier & Annmaria Baby & S Akhila(26523)
Investigation of mechanical and self-healing properties of hydroxyl-terminated polybutadiene functionalized with 2-ureido-4-pyrimidinone by Mohsen Kazazi & Mehran Hayaty & Ali Mousaviazar(26458)